import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        for (int i = 0; i < 99999; i++) {
            int count=0;
            int tmp=0;
            int sum=0;
            tmp=i;
            //求出i有几位数字,为了防止i不变，我们需要找一个替罪羊
            while(tmp!=0){
                count++;
                tmp=tmp/10;
            }

            tmp=i;
            while (tmp!=0){
                sum+=Math.pow(tmp%10,count);
                tmp/=10;
            }
           if(sum==i){
               System.out.println(i);
           }
        }

    }

}